package com.atguigu.gulimall.search.thread;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadTest {
      // 创建 线程池
    private static ExecutorService pool = Executors.newFixedThreadPool(10);





    public static void main(String[] args) throws InterruptedException {
//        System.out.println(Thread.currentThread().getId());
//        System.out.println("start-------------");
//        CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> {
//            System.out.println(Thread.currentThread().getId());
//            int i = 10 / 2;
//            System.out.println(Thread.currentThread().getId()+"----supplyAsync----");
//            return i;
//        }, pool).whenComplete((res,throwable)->{
//            System.out.println(Thread.currentThread().getId()+"----whenComplete--------"+res);
//        });
//
//         Thread.sleep(1000);
//        System.out.println("end-------------");


           CompletableFuture.supplyAsync(()->{
               System.out.println(Thread.currentThread().getId());
               return null;
           },pool).thenRunAsync(()->{
               System.out.println(Thread.currentThread().getId());
           });



    }

















}
